#pragma once

#include "EntityList.h"
#include "BaseEntity.h"
#include "SFML/System.hpp"
#include "SFML/Graphics.hpp"
#include "PhysicsObject.h"
#include "Utility.h"

class PhysicsManager
{
private:
	EntityList* PhysicsEnts;
	std::vector<sf::Vector2f> Simplex;
public:
	PhysicsManager(void);
	~PhysicsManager(void);
	void Tick();
	void RegisterPhysicsEntity(BaseEntity* ent);
	int CheckCollision(PhysicsObject* hull1, PhysicsObject* hull2, CollisionData *CollideInfo);
	int CheckCollision2(PhysicsObject* hull1, PhysicsObject* hull2, CollisionData *CollideInfo);
	bool AABBIntersect(sf::FloatRect &One, sf::FloatRect &Two);
	sf::Vector2f ProjectShape(PhysicsObject* hull, sf::Vector2f Axis);
	float ProjectionOverlap(sf::Vector2f One, sf::Vector2f Two);

	void RemoveEntity(BaseEntity* ent);

	sf::Vector2f Support(PhysicsObject* h1, PhysicsObject *h2, sf::Vector2f dir);
	bool DoSimplex(sf::Vector2f &dir);
	sf::Vector2f TripleProduct(sf::Vector2f A, sf::Vector2f B, sf::Vector2f C);
};

